import 'package:flutter/material.dart';
import 'package:flutter_demo1/dialog/my_dialog.dart';

void main() {
  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: HomePage(),
  ));
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  void openDialog(BuildContext context) {
    showDialog(
        barrierDismissible: false,
        context: context,
        builder: (context) {
          return MyDialog(
            title: "提示信息",
            content: "你确定删除吗？",
            onClosed: () {
              Navigator.pop(context);
            },
          );
        });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Alert"),
      ),
      body: Center(
        child: ElevatedButton(
            onPressed: () {
              openDialog(context);
            },
            child: const Text("打开自定义对话框")),
      ),
    );
  }
}
